package org.example.JVM.ByteCode.Type.CONSTANT;

import org.example.JVM.ByteCode.Type.CpInfo;
import org.example.JVM.ByteCode.Type.U1;
import org.example.JVM.ByteCode.Type.U2;

import java.nio.ByteBuffer;

/**
 * @description: 存储类的符号信息
 * @author: farprt
 * @create: 2022-11-13 15:33
 **/
public class CONSTANT_Class_info extends CpInfo {

    //存储类名
    private U2 name_index;

    public CONSTANT_Class_info(U1 tag) {
        super(tag);
    }

    @Override
    public void read(ByteBuffer codeBuf) throws Exception {
        this.name_index = new U2(codeBuf.get(), codeBuf.get());
    }

    @Override
    public String toString() {
        return super.toString() + ",name_index=#" + this.name_index.toInt();
    }

    public U2 getName_index() {
        return name_index;
    }
}